package tt.dz.order.util.thirdrecord;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;

import org.apache.commons.collections.CollectionUtils;

import tt.dz.order.pojo.OrderInfo;

/**
 * 
 * 
 * @name 公共方法
 * @author Anson
 * @version 1.0
 * @summary
 * @desc
 *
 */
public abstract class AbstractCommonThirdRecordQuery implements ThirdRecordQuery {

	/**
	 * 将orders集合转换map
	 * @param orderInfos
	 * @return
	 */
	protected Map<String, OrderInfo> paramOrder(Collection<OrderInfo> orderInfos) {
		return new OrderMap(orderInfos);
	}

	/**
	 * 
	 * 
	 * @name 订单map
	 * @author Anson
	 * @version 1.0
	 * @summary
	 * @desc key:orderNo value:OrderInfo
	 *
	 */
	protected class OrderMap extends HashMap<String, OrderInfo> {
		/**
		 * 
		 */
		private static final long serialVersionUID = -5558275752960053192L;

		public OrderMap(Collection<OrderInfo> orderInfos) {
			super();

			if (!CollectionUtils.isEmpty(orderInfos)) {
				for (OrderInfo orderInfo : orderInfos) {
					this.put(orderInfo.getOrderNo(), orderInfo);
				}
			}
		}

		public OrderMap(Map<? extends String, ? extends OrderInfo> m) {
			super(m);
		}

	}
}
